#include<iostream>
#include<set>
#include<cmath>

using namespace std;

typedef long long ll;
const int N = 1e5 + 10;
ll a[N], b[N];

set<ll>q;

int main()
{
	int n, m; cin >> n >> m;
	q.insert(-0x3f3f3f3f);
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		q.insert(a[i]);
	}
	ll ret = 0;
	for (int i = 1; i <= m; i++)
	{
		cin >> b[i];
		auto c = q.lower_bound(b[i]);
		ll d = *c; ll e = *(--c);
		ret += min(abs(d - b[i]), abs(e - b[i]));
	}
	cout << ret;

	return 0;
}
